const CryptoJS = require("crypto-js");
const moment = require("moment");

var nowTime = moment().format("YYYYMMDDHHmmss");

var currentParams = {
  h5_channel_id: "006",
  head_area_code: "110000",
  head_iv: "0000000000000000",
  head_jsessionid: "",
  head_osnumber: "ee55713d-42f4-0079-ca76-10b777d9b197",
  head_trans_code: "100101",
  system_id: "hxmark",
  request_time: nowTime,
};

// /**
//  * 对参数进行hmac-md5签名(加密之前)
//  */
function signHmacMd5(params, hmd5Key, signWords) {
  var signString = "";
  var arrays = [];

  for (var i = 0; i < signWords.length; i++) {
    var value = signWords[i];
    params[value] && arrays.push(params[value]);
  }

  if (arrays.length !== 0) {
    signString = arrays.join(" ");
  }

  return CryptoJS.HmacMD5(signString, hmd5Key).toString().toUpperCase();
}
var encodeWords = ['head_jsessionid', 'act_id', 'user_mobile', 'phone', 'is_prize', 'login_name', 'id_code', 'card_no', 'request_time', 'user_name'];
function main(params){
    return signHmacMd5(params, "0B5D1F6E0F4147DF", encodeWords);
}

var headMac =

console.log(headMac);
